{extends file='layout/admin.html'}

{block name='title'}Manage Marquees{/block}

{block name='content'}
<script type="text/javascript" src="js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/upload_file.js"></script>

<div class="clearfix sub_nav"><span class="btn fr"><a href="#" class="add">Add Marquees Ads</a></span></div>

<form action="admin/marquees_manage.html" method="post" accept-charset="utf-8" id="save_add">
	<input type="hidden" name="info[store_id]" value="{$smarty.get.id}">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="content_table" style="display:none">
	<thead>
		<tr style="height: 20px">
			<th class="left">Add Marquees Ads</th>
			<th class="right"></th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td style="width: 30%" class="left_label large tar">Title</td>
			<td class="right_label"><input type="text" class="input_text w420" name="info[title]" /></td>
		</tr>
		<tr>
			<td style="width: 30%" class="left_label large tar">Content</td>
			<td class="right_label"><input type="text" class="input_text w420" name="info[link]" /></td>
		</tr>
		<tr>
			<td style="width: 30%;" class="left_label large tar">Pic URL</td>
			<td class="right_label"><input type="text" class="input_text w420" name="info[pic]" /> <br /><a href="#" class="upload_file">OR UPLOAD FILE: </a></td>
		</tr>
		<tr>
			<td class="large" style="vertical-align: middle;"><span class="btn_sml fr tac neo_sans_intel_light small"><a href="#" class="close">Close</a></span></td>
			<td class="right_label"><input class="btn_save fl" type="submit" value="Save" /></td>
		</tr>
		</tbody>
</table>
</form>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="content_table">
	<thead>
		<tr style="height: 10px">
			<th style="border-left: 1px solid #CCC; width: 65%;" class="left">Title</th>
			<th style="border-left: 1px solid #CCC; width: 15%;">Date Added</th>
			<th style="border-left: 1px solid #CCC; width: 20%;" class="right">Action</th>
		</tr>
	</thead>
	<tbody class="text_indent">
	  {foreach $data as $val}
	  <tr class="odd" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #EEE; background-position: initial initial; background-repeat: initial initial; ">
			<td style="border-right-style: none; border-right-width: initial; border-right-color: initial;">
			  <a href="#" class="m_info">{$val.title}</a>
			  <div class="widget_pops clearfix widget_pops_edit" style="display:none">
					<div class="arrow_top"></div>
					<form action="admin/marquees_manage/update/{$val.id}.html" method="post" accept-charset="utf-8">
					<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bg_white content_table">
						<tbody>
							<tr>
								<td style="width: 30%" class="left_label small tar">Title</td>
								<td class="right_label"><input type="text" class="input_text w290" name="info[title]" value="{$val.title}" /></td>
							</tr>
							<tr>
								<td style="width: 30%" class="left_label small tar">Content</td>
								<td class="right_label"><input type="text" class="input_text w290" name="info[link]" value="{$val.link}" /></td>
							</tr>
							<tr>
								<td style="width: 30%;" class="left_label small tar">Pic URL</td>
								<td class="right_label"><input type="text" class="input_text w290" name="info[pic]" value="{$val.pic}" /> <br /><a href="#" class="upload_file">OR UPLOAD FILE</a></td>
							</tr>
							<tr>
								<td class=""></td>
								<td class="right_label"><span class="btn_sml none_indent fl tac neo_sans_intel_light small"><a href="#" class="save">Save</a></span><span class="btn_sml fl tac neo_sans_intel_light small"><a href="#" class="close1">Close</a></span></td>
							</tr>
							</tbody>
					</table>
					</form>
				</div>
				<div class="widget_pops clearfix widget_pops_info" style="display:none">
						<div class="arrow_top"></div>
						<table width="100%" border="0" cellspacing="0" cellpadding="0" class="bg_white content_table">
							<tbody>
								<tr>
									<td style="width: 35%" class="left_label_text small tar">Title</td>
									<td class="right_label">{$val.title}</td>
								</tr>
								<tr>
									<td style="width: 35%" class="left_label_text small tar">Content</td>
									<td class="right_label">{$val.link}</td>
								</tr>
								<tr>
									<td style="width: 35%;" class="left_label_text small tar">Pic URL</td>
									<td class="right_label" style="width: 55%">{$val.pic}</td>
								</tr>
								</tbody>
						</table>
				</div>
			</td>
			<td style="border-right-style: none; border-right-width: initial; border-right-color: initial;" class="tac">{date('m/d/Y', $val.add_time)}</td>
			<td style="border-right-style: none; border-right-width: initial; border-right-color: initial;" class="tac"><span class="pr20"><a href="#" class="edit">Edit</a></span> | <span class="pl20"><a href="admin/marquees_manage/delete/{$val.id}.html" class="delete">Delete</a></span></td>
		</tr>
	  {/foreach}
	</tbody>
</table>
<div class="clearfix sub_nav">
	<span class="btn fr"><a href="#" class="add">Add Marquees Ads</a></span>
</div>
<script type="text/javascript" charset="utf-8">
dialog_title = 'Manage Marquees';
var PHPSESSID = '{$smarty.cookies.PHPSESSID}';

$('.upload_file').click(function(){
  var p = $(this).parent();
  upload_file(function(file){
    var ext = file.ext.toLowerCase();
    if (ext != 'jpg' && ext != 'jpeg' && ext != 'png' && ext != 'gif') {
      show_msg('u must choose image file!');
      return false;
    }
    $('input', p).val(file.file_path);
  });
  
  return false;
});

$('a.add').click(function(){
  $('.content_table:first').show();

  return false;
});

$('a.close').click(function(){
  $(this).parents('table').hide();
  return false;
});
$('a.close1').click(function(){
  $(this).parents('.widget_pops').hide();
  return false;
});
$('#save_add').submit(function(){

  var self = $(this);
  var title = $('input[name=info[title]]', self);
  var link = $('input[name=info[link]]', self);
  var pic = $('input[name=info[pic]]', self);
  if (!title.val()) {
    show_msg('title is empty', function(){
      title.focus();
    });
    return false;
  }
  if (!link.val()) {
    show_msg('link is empty', function(){
      link.focus();
    });
    return false;
  }
  if (!pic.val()) {
    show_msg('pic is empty', function(){
      pic.focus();
    });
    return false;
  }
  return true;
});

$('a.edit').click(function(){
  $('.widget_pops_edit').hide();
  $('.widget_pops_info').hide();
  
  var tr = $(this).parent().parent().parent();
  $('.widget_pops_edit', tr).show();
  return false;
});

$('a.save').click(function(){
  var self = $(this).parents('.widget_pops_edit');
  var title = $('input[name=info[title]]', self);
  var link = $('input[name=info[link]]', self);
  var pic = $('input[name=info[pic]]', self);
  if (!title.val()) {
    show_msg('title is empty', function(){
      title.focus();
    });
    return false;
  }
  if (!link.val()) {
    show_msg('link is empty', function(){
      link.focus();
    });
    return false;
  }
  if (!pic.val()) {
    show_msg('pic is empty', function(){
      pic.focus();
    });
    return false;
  }
  $('form', self).submit();
  return false;
});

$('.m_info').click(function(){
  $('.widget_pops_edit').hide();
  
  var t = $(this).next().next();
  
  if (t.is(':visible')) {
    t.hide();
  } else {
    $('.widget_pops_info').hide();
    t.show();
  }

  
  return false;
});

$('a.delete').click(function(){
  var url = this.href;
  confirm('Are you sure to delete this?', function(){
    location.href = url;
  });

  return false;
});

</script>
{/block}
